<template>
	<view class="page-container">
		<!-- 标题 -->
		<h1 class="main-title">饮食功能中心</h1>
		<!-- BMI 计算模块 -->
		<navigator url="/pages/bmi/bmi" class="module">
			<h2 class="module-title">BMI 计算</h2>
			<button @click="showBmiModal = true" class="module-button">点击进行 BMI 计算</button>
		</navigator>

		<!-- 食物热量计算模块 -->
		<navigator url="/pages/ce3/ce3" class="module">
			<h2 class="module-title">食物热量计算</h2>
			<button @click="showFoodCalorieModal = true" class="module-button">点击进行食物热量计算</button>
		</navigator>
		<navigator url="/pages/ce2/ce2" class="module">
			<h2 class="module-title">食物相克属性</h2>
			<button class="module-button">点击查看食物相克属性</button>
		</navigator>
	</view>
</template>

<script setup>
	import {
		ref
	} from 'vue';

	// 模态框显示状态
	const showBmiModal = ref(false);
	const showFoodCalorieModal = ref(false);

	// BMI 计算相关数据
	// const bmiHeight = ref('');
	// const bmiWeight = ref('');
	// const bmiResult = ref(null);

	// // 食物热量计算相关数据
	// const foodName = ref('');
	// const foodWeight = ref('');
	// const foodCalorieResult = ref(null);


	// // 计算食物热量（这里简单模拟，假设每克食物 1 大卡）
	// const calculateFoodCalorie = () => {
	// 	if (foodName.value && foodWeight.value) {
	// 		foodCalorieResult.value = parseFloat(foodWeight.value);
	// 	} else {
	// 		alert('请输入有效的食物名称和重量');
	// 	}
	// };
	// showFoodIncompatibility
</script>

<style scoped>
	/* 页面容器 */
	/* 	.page-container {
		max-width: 800px;
		margin: 0 auto;
		padding: 40px;
		background: linear-gradient(145deg, #f4f9f4, #dcedc8);
		border-radius: 20px;
		box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1), 0 3px 6px rgba(0, 0, 0, 0.06);
		animation: fadeIn 0.6s ease;
	} */
	/* 页面容器 */
	.page-container {
		min-height: 100vh;
		/* 确保最小高度为视口高度 */
		width: 100%;
		padding: 40px;
		background: linear-gradient(145deg, #f4f9f4, #dcedc8);
		/* 背景渐变 */
		border-radius: 0;
		/* 移除圆角以铺满边缘 */
		box-shadow: none;
		/* 移除盒子阴影 */
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		/* 垂直居中内容 */
		box-sizing: border-box;
		/* 确保padding和border包含在元素的总宽度和高度内 */
		animation: fadeIn 0.6s ease;
	}

	/* 主标题 */
	.main-title {
		text-align: center;
		color: #2ecc71;
		font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
		font-size: 42px;
		letter-spacing: 2px;
		margin-bottom: 30px;
		position: relative;
	}

	.main-title::after {
		content: '';
		display: block;
		width: 80px;
		height: 4px;
		background: #2ecc71;
		margin: 10px auto 0;
		border-radius: 2px;
	}

	/* 模块样式 */
	.module {
		margin-bottom: 30px;
		padding: 25px;
		background-color: #fff;
		border-radius: 15px;
		box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
		transition: transform 0.3s ease, box-shadow 0.3s ease;
		position: relative;
	}

	.module:hover {
		transform: translateY(-5px);
		box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
	}

	.module-title {
		font-family: 'Roboto', Arial, sans-serif;
		font-size: 28px;
		color: #333;
		margin-bottom: 20px;
		text-align: center;
	}

	.module-button {
		display: block;
		margin: 0 auto;
		padding: 16px 35px;
		background: linear-gradient(135deg, #2ecc71, #27ae60);
		color: white;
		border: none;
		border-radius: 10px;
		cursor: pointer;
		font-size: 18px;
		font-weight: bold;
		transition: background 0.3s ease, transform 0.3s ease;
		box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
	}

	.module-button:hover {
		background: linear-gradient(135deg, #27ae60, #2ecc71);
		transform: scale(1.05);
	}

	/* 模态框 */
	.modal {
		display: flex;
		justify-content: center;
		align-items: center;
		position: fixed;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		background-color: rgba(0, 0, 0, 0.6);
		backdrop-filter: blur(5px);
		z-index: 1000;
	}

	.modal-content {
		background: #fff;
		padding: 30px;
		border-radius: 15px;
		box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
		width: 400px;
		max-width: 90%;
		position: relative;
		animation: modalFadeIn 0.4s ease;
	}

	.close {
		position: absolute;
		top: 10px;
		right: 15px;
		font-size: 28px;
		color: #aaa;
		cursor: pointer;
		transition: color 0.3s ease;
	}

	.close:hover {
		color: #ff4d4d;
	}

	/* 输入框样式 */
	label {
		display: block;
		margin-bottom: 8px;
		font-size: 16px;
		color: #555;
		font-weight: bold;
	}

	input {
		width: 100%;
		padding: 14px;
		margin-bottom: 20px;
		border: 1px solid #ddd;
		border-radius: 8px;
		font-size: 16px;
		transition: border-color 0.3s ease;
	}

	input:focus {
		border-color: #2ecc71;
		outline: none;
		box-shadow: 0 0 5px rgba(46, 204, 113, 0.5);
	}

	/* 计算按钮 */
	.calculate-button {
		padding: 14px 30px;
		background: linear-gradient(135deg, #2ecc71, #27ae60);
		color: white;
		border: none;
		border-radius: 8px;
		cursor: pointer;
		font-size: 16px;
		font-weight: bold;
		transition: background 0.3s ease, transform 0.3s ease;
		box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
	}

	.calculate-button:hover {
		background: linear-gradient(135deg, #27ae60, #2ecc71);
		transform: scale(1.05);
	}

	/* 动画效果 */
	@keyframes fadeIn {
		from {
			opacity: 0;
			transform: translateY(-20px);
		}

		to {
			opacity: 1;
			transform: translateY(0);
		}
	}

	@keyframes modalFadeIn {
		from {
			opacity: 0;
			transform: scale(0.95);
		}

		to {
			opacity: 1;
			transform: scale(1);
		}
	}
</style>